package com.boss.asset.api.v2;

import com.boss.api.dto.ApiResultDTO;
import com.boss.asset.service.IAssetInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




@RestController
@RequestMapping(path = "/v2", produces = MediaType.APPLICATION_JSON_VALUE)
public class AssetApiController{
    @Autowired
    private IAssetInfoService assetInfoService;

    private static final Logger logger = LoggerFactory.getLogger(AssetApiController.class);

    /**
     * 查询资产信息数据
     * @param agencycode
     * @param province
     * @param year
     * @return
     */
    @GetMapping(path = "/asserts")
    public ApiResultDTO getAssetInfos(@RequestParam(value = "agencycode", required = false)String agencycode,
                                    @RequestParam("province")String province,
                                    @RequestParam("year")String year){
        try {
            return ApiResultDTO.success(assetInfoService.queryAssetInfo(agencycode, province, year));
        } catch (Exception e) {
            logger.error("调用 getAssetInfos 方法异常： " + e.getMessage(), e);
            return ApiResultDTO.error("199999", e.getMessage());
        }
    }



}
